home *** CD-ROM | disk | FTP | other *** search
- Subject: Sticky text
- Date: Thu, 05 May 1994 18:23:15 -0700
- From: Howard Chu <howard@harry.lloyd.com>
-
- This is what I originally wanted for shared-text programs under MiNT, but kept
- forgetting to take that last step. With this patch, shared-text memory regions
- stay in memory even after the last process using the region exits. That way
- the region can be used again if the same program is rerun in the future, saving
- load time. Unattached shared-text regions are reclaimed in get_region when
- memory is running low, so the overall impact shouldn't cause you to run out
- of memory any more often than before.
-
- This patch goes a long way toward making my pre-loaded RAMdisk /bin obsolete.
- GCC compiles go a lot faster too, but then, I've got spare RAM to throw at it.
- -- Howard
-
- --- 1.2 1994/03/02 08:06:50
- +++ mem.c 1994/04/27 02:18:44
- @@ -577,5 +577,5 @@
- int mode;
- {
- - MEMREGION *m, *n;
- + MEMREGION *m, *n, *s;
-
- TRACELOW(("get_region(%s,%lx,%x)",
- @@ -591,7 +591,6 @@
- size = ROUND(size);
-
- - n = *map;
- -
- sanity_check(map);
- +
- /* exact matches are likely to be rare, so we pre-allocate a new
- * region here; this helps us to avoid re-entrancy problems
- @@ -600,4 +599,11 @@
- m = new_region();
-
- +/* We come back and try again if we found and freed any unattached shared
- + * text regions.
- + */
- +retry:
- + s = NULL;
- +
- + n = *map;
- while (n) {
- if (ISFREE(n)) {
- @@ -623,8 +629,21 @@
- }
- }
- +/* If this is an unattached shared text region, leave it as a last resort */
- + } else if (n->links == 0xffff && (n->mflags & M_SHTEXT)) {
- + if (!s)
- + s = n;
- }
- n = n->next;
- }
-
- +/* Looks like we're out of free memory. Try freeing an unattached shared text
- + * region, and then try again to fill this request.
- + */
- + if (s) {
- + s->links = 0;
- + free_region(s);
- + goto retry;
- + }
- +
- if (m)
- dispose_region(m);
- @@ -1295,4 +1314,8 @@
- {
- m = s->text;
- +/* Kludge for unattached shared region */
- + if (m->links == 0xffff)
- + m->links = 0;
- +
- if (attach_region(curproc, m)) {
- TRACE(("re-using shared text region %lx", m));
- --- 1.3 1994/05/05 18:04:18
- +++ dosmem.c 1994/04/27 02:13:44
- @@ -832,6 +832,12 @@
- }
- m->links--;
- +/* Leave shared text regions in memory, get_region will reclaim them if
- + memory runs low. Assume that we will never have 65535 processes
- + using a particular memory region. */
- if (m->links == 0) {
- - free_region(m);
- + if (m->mflags & M_SHTEXT)
- + m->links = 0xffff;
- + else
- + free_region(m);
- }
- }
-